home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1991 / 04 / stripit.bas < prev    next >
BASIC Source File  |  1991-03-27  |  3KB  |  57 lines

  1. '***********************************************************************
  2. '                             STRIPIT.BAS                              *
  3. '     STRIPIT deletes any extraneous <LF> characters inserted into the *
  4. ' page heading of a MASM listing (LST) file by the bug in MASM 5.10.   *
  5. ' (The erroneous LST files occur only on dates in which both the month *
  6. ' and the day are given by single digits.)  The original file will be  *
  7. ' replaced by the "stripped" file.                                     *
  8. '                   Written by M. L. Lesser, 2/14/91                   *
  9. '            Compiled with Microsoft BC v 7.1, switch "/O"             *
  10. '   Linked to stub files NOFLTIN, NOCOM, and NOLPT, switches "E/NOE"   *
  11. '***********************************************************************
  12.     DEFSTR F, T: DEFINT I, L
  13.     LET FILE.OUT = COMMAND$             '<filespec> from command line
  14.     IF LEN(FILE.OUT) = 0 THEN
  15.         PRINT: PRINT "No input <filespec> on command line."
  16.         PRINT "     Usage:  Call with STRIPIT <filespec>"
  17.         PRINT "             where <filespec> is a MASM .LST file."
  18.         END
  19.     END IF
  20. ' Force FILE.OUT to have .LST extension:
  21.     LET I = INSTR(FILE.OUT,".")
  22.     IF I <> 0 THEN LET FILE.OUT = LEFT$(FILE.OUT,I)
  23.     LET FILE.OUT = FILE.OUT + ".LST"
  24.     COLOR 2,0                                      'Dealer's choice
  25.     PRINT "Stripping extraneous <LF>s from "; FILE.OUT
  26.     PRINT TAB(5) "Renaming "; FILE.OUT; " to $$$.$$$"
  27.     NAME FILE.OUT AS "$$$.$$$"
  28.     PRINT TAB(5) "Filtering $$$.$$$ to produce new "; FILE.OUT
  29.     OPEN "$$$.$$$" FOR INPUT AS #1 LEN=5120       'Use 5KB buffer
  30.     OPEN FILE.OUT FOR OUTPUT AS #2 LEN=5120
  31.     WHILE NOT EOF(1)
  32.         LINE INPUT #1, TEXT
  33.         IF LEN(TEXT) <> 0 AND ASC(TEXT) = 12 THEN    'Header-line check
  34. ' Note:  To prevent an "Illegal function call" runtime error if compiled
  35. '      with BC version 4.5, comment out the statement above this note;
  36. '      use the three commented-out (nested IF block) statements below
  37. '        IF LEN(TEXT) <> 0 THEN
  38. '          IF ASC(TEXT) = 12 THEN
  39.             LET I = INSTR(TEXT,CHR$(10))        '  (marked by <FF>)
  40.             IF I <> 0 THEN                      '  for extraneous <LF>
  41.                 LET TEXT = LEFT$(TEXT,I-1) + MID$(TEXT,I+1)
  42.                 LET LINE.NO = LINE.NO + 1
  43.             END IF
  44.  '         END IF    
  45.         END IF
  46.         LET LINE.NO = LINE.NO + 1
  47.         LOCATE ,1                               'Display filter progress
  48.         PRINT TAB(10) "Filtering line" LINE.NO; ' by overprinting
  49.         PRINT #2, TEXT
  50.      WEND
  51.      PRINT
  52.      CLOSE
  53.      PRINT TAB(5) "Deleting $$$.$$$"
  54.      KILL "$$$.$$$"
  55.      PRINT "STRIPIT ran to completion."
  56.      END
  57.